// Main.cpp
#include "DIHandler.h"
#include "DOHandler.h"
#include "UARTHandler.h"
#include <iostream>
#include <string>
#include <memory>

int main() {
    // 模拟接收到的数据
    std::string data = "{\"protocolType\": 1, \"msgId\": \"00001\", \"command\": \"00000001,00000003,...\"}";
    
    // 解析数据并确定协议类型
    int protocolType = 0; // 假设这是从data中解析出的协议类型
    switch (protocolType) {
        case 0: { // DI
            std::unique_ptr<ProtocolHandler> handler(new DIHandler());
            handler->handleCommand(data);
            break;
        }m
        case 1: { // DO
            std::unique_ptr<ProtocolHandler> handler(new DOHandler());
            handler->handleCommand(data);
            break;
        }
        case 2: { // UART
            std::unique_ptr<ProtocolHandler> handler(new UARTHandler());
            handler->handleCommand(data);
            break;
        }
        default:
            std::cout << "Unknown protocol type" << std::endl;
            break;
    }

    return 0;
}